package cn.laike.modules.dev.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Maps;

import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.Query;

import cn.laike.modules.dev.dao.WithdrawalLogDao;
import cn.laike.modules.dev.entity.WithdrawalLogEntity;
import cn.laike.modules.dev.service.WithdrawalLogService;


@Service("withdrawalLogService")
public class WithdrawalLogServiceImpl extends ServiceImpl<WithdrawalLogDao, WithdrawalLogEntity> implements WithdrawalLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<WithdrawalLogEntity> page = this.selectPage(
                new Query<WithdrawalLogEntity>(params).getPage(),
                new EntityWrapper<WithdrawalLogEntity>()
        );

        return new PageUtils(page);
    }

	@Override
	public List<Map> queryWithdrawalLogList(String openid, Integer pageNo, Integer pageSize) {
		return baseMapper.queryWithdrawalLogList(openid, (pageNo - 1)*pageSize, pageSize);
	}

	@Override
	public Map getLastWithdrawal(String openid) {
		List<Map> list = baseMapper.queryLastWithdrawal(openid);
		return (list != null && list.size() > 0) ? list.get(0) : Maps.newConcurrentMap();
	}

}
